package tree;

public class BinaryNode<T>                       //二叉树的二叉链表结点类，T指定结点的元素类型
{
    public T data;                               //数据域，存储数据元素
    public BinaryNode<T> left, right;            //链域，分别指向左、右孩子结点

    //构造结点，data指定元素，left、right分别指向左孩子和右孩子结点
    public BinaryNode(T data, BinaryNode<T> left, BinaryNode<T> right) {
        this.data = data;
        this.left = left;
        this.right = right;
    }

    public BinaryNode(T data) {
        this(data, null, null);
    }

    public String toString() {
        return this.data.toString();
    }

    public boolean isLeaf() {
        return this.left == null && this.right == null;
    }
}